import com.jerry.weixing.domain.AcessToken;
import com.jerry.weixing.util.httpUtil;
import com.sun.deploy.net.HttpUtils;
import net.sf.json.JSONObject;

import java.io.IOException;
import java.security.AccessControlContext;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;

/**
 * Created by admin on 2016/10/9.
 */
public class testAcesstoken {
    public static void main(String[] args) throws KeyManagementException, NoSuchAlgorithmException, NoSuchProviderException, IOException {
        AcessToken acessToken = httpUtil.getToken();
        System.out.println("票据："+acessToken.getAccess_token());
        System.out.println("时间："+acessToken.getExpires_in());

        String filePath ="C:/Users/admin/Pictures/Camera Roll/9c13c40ef27caefdf86c59048cde9f0d1d861f8d5db505-TF4D1F_fw658.jpg";

        String filePath1 ="C:/Users/admin/Pictures/Camera Roll/QQ图片20161010000046.png";

        String filePath2 = "C:/Users/admin/Pictures/Camera Roll/QQ图片20161010001814.png";

//        String medid = httpUtil.upload(filePath,acessToken.getAccess_token(),"image");
//        System.out.println(medid);
//
//        String medid1 = httpUtil.upload(filePath1,acessToken.getAccess_token(),"thumb");
//        System.out.println(medid1);

//        String medid2 = httpUtil.upload(filePath2,acessToken.getAccess_token(),"thumb");
//        System.out.println(medid2);

    //       String menu =  JSONObject.fromObject(httpUtil.initMenu()).toString();
    //        int result = httpUtil.createMenu(acessToken.getAccess_token(),menu);
    //        if(result == 0){
    //            System.out.println("菜单创建成功");
    //        }else{
    //            System.out.println("菜单创建失败：原因是"+result);
    //        }
//        JSONObject obj =httpUtil.queryMenu(acessToken.getAccess_token());
//        System.out.println(obj);

        int result = httpUtil.deleteMenu(acessToken.getAccess_token());
        if(result == 0){
            System.out.println("菜单删除成功");
        }else{
            System.out.println(result);
        }
    }
}
